package be.jabapage.snooker.service.competition.api;

import java.util.Set;

import be.jabapage.snooker.exception.EntityNotFoundException;
import be.jabapage.snooker.exception.MultipleInstanceFoundException;
import be.jabapage.snooker.jdo.competition.Competition;

/**
 * 
 * CRUD service for the Competition
 * @author axesq
 *
 */
public interface ICompetitionService {

	/**
	 * 
	 * Store or update a Competition in the data store
	 * @param Competition
	 */
	void store(Competition competition);

	/**
	 * Retrieve a Competition by the key
	 * @param key
	 * @return Competition
	 * @throws EntityNotFoundException when no record is found
	 */
	Competition retrieve(Long key) throws EntityNotFoundException;

	/**
	 * Delete the instance with this key from the datastore.
	 * @param key
	 * @throws EntityNotFoundException when the instance is not found;
	 */
	void delete(Long key) throws EntityNotFoundException;

	/**
	 * Retrieve a Competition by the name
	 * @param name
	 * @return
	 * @throws MultipleInstanceFoundException when more then one instance is found.
	 * @throws EntityNotFoundException when no record is found
	 */
	Competition retrieve(String name) throws MultipleInstanceFoundException, EntityNotFoundException;

	/**
	 * Retrieves a list of Competition depending on the search criteria.  Wildcards are allowed.
	 * @param level
	 * @return a {@link Set}
	 */
	Set<Competition> search(String level);

	/**
	 * Retrieves a set of Competition that belongs to a certain region.
	 * @param regionId
	 * @return
	 */
	Set<Competition> retrieveAllForRegion(Long regionId);
}
